import { defineConfig, loadEnv } from "vite";
import vue from "@vitejs/plugin-vue";
import WindiCSS from "vite-plugin-windicss";
import path, { resolve } from "path";
// https://vitejs.dev/config/
export default defineConfig(({ command, mode }) => {
  const root = process.cwd();
  const env = loadEnv(mode, root);
  return {
    plugins: [vue(), WindiCSS()],
    // 配置绝对路径，指定src文件夹
    resolve: {
      alias: {
        "~": path.resolve(__dirname, "src"),
      },
    },
    server: {
      proxy: {
        [env.VITE_APP_BASE_API]: {
          target: env.VITE_APP_BASE_ONLINE_TARGET_API,
          ws: true,
          changeOrigin: true,
          rewrite: (path) => path.replace(env.VITE_APP_BASE_API, ""),
        },
      },
    },
  };
});
